package com.ruoyi.service.impl;

import com.ruoyi.domain.AdvTemple;
import com.ruoyi.mapper.AdvTempleMapper;
import com.ruoyi.service.AdvTempleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdvTempleServiceImpl implements AdvTempleService {

    @Autowired
    private AdvTempleMapper advTempleMapper;

    @Override
    public List<AdvTemple> selectAdvTempleList(AdvTemple advTemple) {
        return advTempleMapper.selectAdvTempleList(advTemple);
    }

    @Override
    public int insertAdvTemple(AdvTemple advTemple) {
        return advTempleMapper.insertAdvTemple(advTemple);
    }

    @Override
    public int updateAdvTemple(AdvTemple advTemple) {
        return advTempleMapper.updateAdvTemple(advTemple);
    }

    @Override
    public int deleteAdvTempleByAdvTempleId(Long[] advTempleIds) {
        try {
            return advTempleMapper.deleteAdvTempleByAdvTempleId(advTempleIds);
        }catch (DataIntegrityViolationException e){
            throw new RuntimeException("请先删除寺庙管理相关联数据");
        }
    }
}
